<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>北京航天公司固定资产管理系统</title>
</head>
<body>
<div class="layui-tab">
    <ul class="layui-tab-title">
        <li class="layui-this">资产报修</li>
        <li>提报历史</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">

            <br><br>
            <button class="layui-btn" id="return">返回</button>


            <button class="layui-btn" id="passBtn" th:if="${userInfo.type} =='部门经理'">通过</button>
            <button class="layui-btn" id="passBtn" th:if="${userInfo.type} =='财务部经理'">通过</button>


            <button class="layui-btn layui-btn-danger" th:if="${userInfo.type} =='部门经理'" id="forbidBtn">不通过</button>
            <button class="layui-btn layui-btn-danger" th:if="${userInfo.type} =='财务部经理'" id="forbidBtn">不通过</button>
            <br><br>

            <div class="layui-inline">
                <div class="layui-col-xs6 layui-col-md4">
                    <blockquote class="layui-elem-quote" style="width: 1450px;">故障信息</blockquote>
                    <br>
                </div>
            </div>
            <form class="layui-form" action="">
        <!-- //复选框的显示 待删除-->
            <!--<div class="layui-form-item">
                <label class="layui-form-label" style="background-color: #ececec">复选框</label>
                <div class="layui-input-block">


                   &lt;!&ndash; <option th:selected="${goods.brandId eq b['id']}" th:each="b:${brandList}" th:value="${b['id']}" th:text="${b['abc']}+'&#45;&#45;'+${b['name']}" value="1">耐克</option>

                    &lt;!&ndash; roleList:所有角色信息 ；userRoleList:用户已有角色id列表&ndash;&gt;
                    <input th:each="role:${roleList}"  type="checkbox"  th:value="${role.id}" th:checked="${#lists.contains(userRoleList, role.id)}" th:text="${role.role_name}">


                    <input type="checkbox" th:each="list : ${FaulttypeList}"  th:each="ids :${FaulttypeId}"  th:checked="${list.id eq ids.id} eq ${ids.id}"   th:value="${list.id}"
                           th:title="${list.faultname}">&ndash;&gt;

                </div>
            </div>-->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">图片</label>
                    <div class="layui-input-inline">
                        <img id="preview_photo" th:src="${scrapphoto.photo}" width="200%">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">申请日期</label>
                    <div class="layui-input-inline">
                        <input type="text" id="appDate" th:value="${scrap.start_scrap_time}" readonly lay-verify="email"
                               autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label" style="background-color: #ececec">报修单号</label>
                    <div class="layui-input-inline">
                        <input type="text" id="scrap_id" th:value="${scrap.scrap_id}" readonly lay-verify="email"
                               autocomplete="off" class="layui-input" >
                    </div>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label" style="background-color: #ececec">备注</label>
                <div class="layui-input-block">
        <textarea placeholder="请输入内容" id="content" name="content"
                  class="layui-textarea">[[${scrap?.scrap_description}]]</textarea>
                </div>
            </div>
            </form>
            <div class="layui-inline">
                <div class="layui-col-xs6 layui-col-md4">
                    <blockquote class="layui-elem-quote" style="width: 1450px;">资产信息</blockquote>
                    <br>
                </div>
            </div>

            <div class="layui-form-item">
                <input type="hidden" th:value="${scrap.apply_state}" id="apply_state">
                <input type="hidden" th:value="${userInfo.rankNum}" name="final_approver_name" id="rankNum">
                <input type="hidden" th:value="${userInfo.rname}" name="rname" id="rname">
                <input type="hidden" th:value="${userInfo.uname}" name="uname" id="uname">

                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">所属组织</label>
                    <div class="layui-input-inline">
                        <div class="layui-btn-inline">
                            <input type="text" readonly th:value="${scrap.organisation}" lay-verify="email"
                                   autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">所属部门</label>
                    <div class="layui-input-inline">
                        <input type="text" readonly th:value="${scrap.dname}" lay-verify="email" autocomplete="off"
                               class="layui-input">
                    </div>

                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">责任人</label>
                    <div class="layui-input-inline">
                        <input type="text" th:value="${scrap.responsible}" readonly lay-verify="email"
                               autocomplete="off"
                               id="responsible" name="responsible" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">资产编号</label>
                    <div class="layui-input-inline">
                        <input type="text" id="property_id" th:value="${scrap.property_id}" readonly
                               lay-verify="required|phone" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">维修申请人</label>
                    <div class="layui-input-inline">
                        <input type="text" th:value="${scrap.scrap_operator}" readonly lay-verify="required|phone"
                               id="scrap_operator" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-col-xs6 layui-col-md4">
                    <blockquote class="layui-elem-quote" style="width: 1450px;">审核状态</blockquote>
                    <br>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="background-color: #ececec">当前状态：</label>
                    <div class="layui-input-inline">
                        &nbsp;&nbsp;&nbsp;
                        <span th:if="${scrap.check_statu_id==1}" style="color: blue" th:text="'***等待一级审批***'"></span>
                        <span th:if="${scrap.check_statu_id==2}" style="color: blue" th:text="'***等待最终审批***'"></span>
                        <span th:if="${scrap.check_statu_id==3}" style="color: red" th:text="'***已驳回***'"></span>
                        <span th:if="${scrap.check_statu_id==4}" style="color: green" th:text="'***审批完成***'"></span>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-tab-item">
            <table id="myTable"></table>
        </div>
    </div>
</div>


</body>
</html>
<script type="text/javascript" src="/js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="/layui/layui.all.js"></script>
<link rel="stylesheet" href="/layui/css/layui.css">
<script type="text/javascript">

    var form = layui.form;
    var table = layui.table;
    $(function () {
        form.render();


    })

    var propertyId = $("#scrap_id").val();
    console.log(propertyId);
    table.render({
        elem: '#myTable',//绑定表格的id
        url: "/scrap/SelectHistory?scrap_id=" + propertyId,
        width: 1500,
        height: 312,
        method: 'post',
        autoSort: false,
        toolbar: '#toolbarDemo', //开启头部工具栏
        cols: [[{
            field: 'scrap_id',
            title: '报修单号',
            align: 'center',//字体居中
        }, {
            field: 'apply_state',
            title: '报修审核状态',
            align: 'center',//字体居中
            templet: function (d) {
                if (d.apply_state == 1) {
                    return "<span style='color: blue'>●一级审批</span>"
                } else if (d.apply_state == 0) {
                    return "<span style='color: blue'>●提出申请</span>"
                } else if (d.apply_state == 2) {
                    return "<span style='color: blue'>●一级审批</span>"
                } else if (d.apply_state == 3) {
                    return "<span style='color: red'>●已驳回</span>"
                } else if (d.apply_state == 4) {
                    return "<span style='color: green'>●审批完成</span>"
                } else if (d.apply_state == null) {
                    return "<span></span>"
                }
            }
        }, {
            field: 'auditor',
            title: '审核人',
            align: 'center',//字体居中
        }, {
            field: 'auditrole',
            title: '审核角色',
            align: 'center',//字体居中
        }, {
            field: 'responsible',
            title: '资产责任人',
            align: 'center',//字体居中
        }, {
            field: 'scrap_operator',
            title: '报修申请人',
            align: 'center',//字体居中
        }, {
            field: 'audittime',
            title: '结束时间',
            align: 'center',//字体居中
            sort: true
            /* templet : '#sexTpl',//绑定代码模板 暂时用不到 男女 * */
        }]
        ],
        limits: [3, 5],//每页条数的选择项，默认：[10,20,30,40,50,60,70,80,90]。
        limit: 3,//每页显示的条数（默认：10）。值务必对应 limits 参数的选项。
        page: false,//是否开启分页
        request: {
            pageName: 'page',
            limitName: 'limit'
        }
    });


    //返回
    $("#return").click(function () {
        window.location.href = "/jump/goScrapIndex"
    })

    /*通过*/
    $("#passBtn").click(function () {
        var apply_state = $("#apply_state").val();
        var scrap_id = $("#scrap_id").val();
        var scrap_operator = $("#scrap_operator").val();
        var responsible = $("#responsible").val();

        var rname = $("#rname").val();
        var uname = $("#uname").val();
        var rankNum = $("#rankNum").val();
        $.post("/scrap/Processaudit?apply_state=" + apply_state + "&uname=" + uname + "&scrap_id=" + scrap_id
            + "&scrap_operator=" + scrap_operator + "&rname=" + rname + "&rankNum=" + rankNum + "&responsible=" + responsible, function (res) {
            alert(res)
            window.location.href = "/jump/goScrapIndex"
        }, "text")
    })

    /*不通过*/
    $("#forbidBtn").click(function () {
        var apply_state = $("#apply_state").val();
        var scrap_id = $("#scrap_id").val();
        var scrap_operator = $("#scrap_operator").val();
        var responsible = $("#responsible").val()

        var rname = $("#rname").val();
        var uname = $("#uname").val();
        var rankNum = $("#rankNum").val();
        $.post("/scrap/refuse?apply_state=" + apply_state + "&uname=" + uname + "&scrap_id=" + scrap_id
            + "&scrap_operator=" + scrap_operator + "&rname=" + rname + "&rankNum=" + rankNum + "&responsible=" + responsible, function (res) {
            alert(res)
            window.location.href = "/jump/goScrapIndex"
        }, "text")
    })

</script>